import { create } from "zustand";
// 定义状态的类型
interface ResultState {
  key?: string;
  result: any; // 你也可以改成具体类型，如：{ id: string; name: string } | null
  setResult: (key: string, data: any) => void;
  clearResult: (key: string) => void;
}
export const useResultStore = create<ResultState>((set,get) => ({
  key: undefined,
  result: undefined,
  setResult: (key, data) => set({ key, result: data }),
  clearResult: (key) => {
    const current = get();
    if (current.key === key) set({ key: undefined, result: undefined });
  },
}))